home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
user
/
cup_cupinformation.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
17KB
|
620 lines
/* Mode=Run */
/* ***********************************************************************
CUP INFORMATION PROGRAM FOR FOOTBALL REXX SUITE
-------------------------------------------------
Copyright Mark Naughton 1998
Version Date History
--------------------------------------------------------------------------
1.0 140998 First release.
160998 Changed way best record is calculated.
250899 Added error msg to file check.
050999 Converted to use locale. Some error messages, before
reading the locale, will still be in English.
050999 Report shows better words for the settings for the
rounds - Have decided to keep the datafile settings in
English for easier controls - looks better though....
**************************************************************************
Procedure
---------
1. Check files exist.
2. Read '.cf' file and get details. Read '.cfrw' and do the same.
3. If '.cfsave' doesn't exist, read the '.scf' file adjusting the output
for replays, extra time, first leg and penalties.
4. If '.cfsave' is found, read to display current matches.
5. Read '.scf' into an array. Search array, storing goals. When finished,
search through the team array, calculating the best record :
(Goals Scored / Goals Away) * Matches Played
Goals Scored = Goals Scored At Home + (Goals Scored Away * 1.5)
6. Write data to a file and call an external sort program. Read the details
back in and delete the temporary file.
7. Adjust options.
8. Display report : display options/rounds, teams and the best record, the
current round matches and if the history file has been selected, read
the file for previous/current winners.
9. Exit.
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.cf'
input2_file = '.scf'
input3_file = '.cfrw'
input4_file = '.cfh'
input5_file = '.cfsave'
output_file = 'RAM:Football.tempcup'
title = '*CUP_TITLE='
thirdpl = '*CUP_THIRD='
rounddef = '*CUP_RNDDEF='
currond = '*CUP_ROND='
currrondn = '*CUP_CRDN='
roundddef = '*CUP_RDEF='
cuphistory = '*CUP_HISTORY='
thirdpl = '*CUP_THIRD='
teams_cnt = '*CUP_TCNT='
awaygs = '*CUP_AWAYG='
schedtype = '*CUP_SCHEDULE='
first = '*WINNER='
pkversion = '* Version='
matches. = '???'
separator = '*'
teams. = '???'
rnds. = '???'
lines. = '???'
replays. = '???'
working. = '???'
losing. = '???'
repct = 0
repno. = '???'
tcount = 0
ttc = 0
rndcnt = 0
linesct = 0
/* league_file = "Data/"league_stuff */
curnd = ''
curndn = 0
not_played = "__ __"
mcount = 0
bstats. = '???'
btemp. = '???'
btcnt = 0
bpstats. = '???'
bgsstats. = '???'
bgastats. = '???'
bagstats. = '???'
parse var league_stuff league_file search_team
league_file = "Data/" || league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (CupInformation)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
dcupdir = locdir"Football.locale_cup"
locdir = locdir"User/Cup_CupInformation.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (CupInformation)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
if exists(dcupdir) > 0 then do
address command rxdir'rx 'dcupdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (CupInformation)"
say
say "Cannot find '"dcupdir"' to read cup locale settings."
exit
end
if exists(league_file || input_file) = 0 then do
say
say ci_error
say
say ci_t1"'"league_file || input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say ci_error
say
say ci_t1"'"league_file || input2_file"'."
exit
end
tcount = 0
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(title,line) > 0 then cupname = delstr(line,1,11)
if pos(thirdpl,line) > 0 then third = delstr(line,1,11)
if pos(awaygs,line) > 0 then awaygoals= delstr(line,1,11)
if pos(pkversion,line) > 0 then fversion = delstr(line,1,12)
if pos(cuphistory,line) > 0 then cuph = delstr(line,1,13)
if pos(schedtype,line) > 0 then scht = delstr(line,1,14)
if pos(rounddef,line) > 0 then do
rndcnt = rndcnt + 1
rnds.rndcnt = delstr(line,1,12)
end
if pos(separator,line) = 0 then do
line = strip(line)
tcount = tcount + 1
teams.tcount = line
end
end
close(datafile)
end
else do
say
say ci_error
say
say ci_t2"'"league_file || input_file"'."
exit
end
if open(datafile,league_file || input3_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(currond,line) > 0 then crond = strip(substr(line,11,2))
if pos(roundddef,line) > 0 then tcrondn= strip(substr(line,11,5))
if pos(currrondn,line) > 0 then do
crondn = strip(substr(line,11,30))
tleg_no = 0
if pos("1 Leg",line) > 0 then tleg_no = 1
if pos("2 Legs",line) > 0 then tleg_no = 2
end
end
close(datafile)
end
else do
say
say ci_error
say
say ci_t2"'"league_file || input3_file"'."
exit
end
a = 0
mcount = 0
if exists(league_file || input5_file) = 0 then do
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos("*Round="strip(tcrondn),line) > 0 then
a = 1
if a = 1 then do
if pos(separator,line) = 0 & pos('#',line) = 0 then do
mcount = mcount + 1
matches.mcount = line
end
else do
if pos("Replay",line) > 0 then do
mcount = mcount + 1
matches.mcount = " "
mcount = mcount + 1
matches.mcount = cs_t31
mcount = mcount + 1
matches.mcount = ""
do cil=1 to length(cs_t31)
matches.mcount = matches.mcount||"-"
end
mcount = mcount + 1
matches.mcount = " "
end
if pos("#1st Leg",line) > 0 then do
mcount = mcount + 1
matches.mcount = overlay("--"ci_t3||cum_t32,line,1,length(ci_t3||cum_t32)+2)
end
if pos("#Score After Extra Time",line) > 0 then do
mcount = mcount + 1
matches.mcount = overlay("--"cup_saet,line,1,length(cup_saet)+2)
end
if pos("#Penalties",line) > 0 then do
mcount = mcount + 1
matches.mcount = overlay("--"ci_t3||strip(fc_t8),line,1,length(ci_t3||strip(fc_t8))+2)
end
end
end
end
close(datafile)
end
else do
say
say ci_error
say
say ci_t2"'"league_file||input2_file"'"ci_t4
exit
end
end
else do
if open(datafile,league_file || input5_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 & pos('#',line) = 0 then do
mcount = mcount + 1
matches.mcount = line
end
else do
if pos(not_played,line) = 0 then do
if pos("Replay",line) > 0 then do
mcount = mcount + 1
matches.mcount = " "
mcount = mcount + 1
matches.mcount = cs_t31
mcount = mcount + 1
matches.mcount = ""
do cil=1 to length(cs_t31)
matches.mcount = matches.mcount||"-"
end
mcount = mcount + 1
matches.mcount = " "
end
if pos("#1st Leg",line) > 0 then do
mcount = mcount + 1
matches.mcount = line
matches.mcount = overlay("--"ci_t3||cum_t32,line,1,length(ci_t3||cum_t32)+2)
end
if pos("#Score After Extra Time",line) > 0 then do
mcount = mcount + 1
matches.mcount = line
matches.mcount = overlay("--"cup_saet,line,1,length(cup_saet)+2)
end
if pos("#Penalties",line) > 0 then do
mcount = mcount + 1
matches.mcount = line
matches.mcount = overlay("--"ci_t3||strip(fc_t8),line,1,length(ci_t3||strip(fc_t8))+2)
end
end
end
end
close(datafile)
end
else do
say
say ci_error
say
say ci_t2"'"league_file||input5_file"'"ci_t4
exit
end
end
do i=1 to tcount
bpstats.i = 0
bgsstats.i = 0
bgastats.i = 0
bagstats.i = 0
end
np = 0
btcnt = 0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
btcnt = btcnt + 1
btemp.btcnt = line
end
close(datafile)
end
else do
say
say ci_error
say
say ci_t2"'"league_file||input2_file"'"ci_t4
exit
end
do k=1 to btcnt
if pos(not_played,btemp.k) = 0 & pos(separator,btemp.k) = 0 & pos('#',btemp.k) = 0 then do
teama = strip(substr(btemp.k,1,30))
teamb = strip(substr(btemp.k,41,30))
np = 1
do l=1 to tcount
if pos(teama,teams.l) > 0 then do
bpstats.l = bpstats.l + 1
l11 = k + 1
if pos("#1st Leg",btemp.l11) > 0 then
l11 = k + 2
if pos("Extra Time",btemp.l11) = 0 then do
bgsstats.l = bgsstats.l + strip(substr(btemp.k,32,2))
bgastats.l = bgastats.l + strip(substr(btemp.k,37,2))
end
else do
bgsstats.l = bgsstats.l + strip(substr(btemp.l11,32,2))
bgastats.l = bgastats.l + strip(substr(btemp.l11,37,2))
end
end
if pos(teamb,teams.l) > 0 then do
bpstats.l = bpstats.l + 1
l11 = k + 1
if pos("#1st Leg",btemp.l11) > 0 then
l11 = k + 2
if pos("Extra Time",btemp.l11) = 0 then do
bagstats.l = bagstats.l + strip(substr(btemp.k,37,2))
bgastats.l = bgastats.l + strip(substr(btemp.k,32,2))
end
else do
bagstats.l = bagstats.l + strip(substr(btemp.l11,37,2))
bgastats.l = bgastats.l + strip(substr(btemp.l11,32,2))
end
end
end
end
end
if open(datafile,output_file,'w') then do
do i=1 to tcount
if bpstats.i = "" | bgsstats.i = "" | bgastats.i = "" | bagstats.i = "" then iterate
if bgastats.i = 0 then
/* average = "0.000" */
average = trunc((bgsstats.i + (bagstats.i * 1.5))*bpstats.i,3)
else
average = trunc(((bgsstats.i + (bagstats.i * 1.5))/bgastats.i)*bpstats.i,3)
bstats.i = right(average,7)" "left(teams.i,30,' ')" "left(bpstats.i,3,' ')" "left(bgsstats.i+bagstats.i,3,' ')" "left(bgastats.i,3,' ')
writeln(datafile,bstats.i)
end
close(datafile)
address command 'Exec/Sort7Chars'
btcnt = 0
if open(datafile,output_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if line ~= "" then do
btcnt = btcnt + 1
bstats.btcnt = substr(line,9)" "substr(line,1,8)
end
end
close(datafile)
address command 'c:delete >NIL: 'output_file
end
else do
say
say ci_error
say
say ci_t2"'"output_file"'"ci_t4
exit
end
end
else do
say
say ci_error
say
say ci_t2"'"output_file"'"ci_t5
exit
end
if pos("YES",cuph) > 0 then
cuph = left(ci_t8,3," ")
else
cuph = left(ci_t9,3," ")
if pos("YES",third) > 0 then
third = left(ci_t8,3," ")
else
third = left(ci_t9,3," ")
if pos("YES",awaygoals) > 0 then
awaygoals = left(ci_t8,3," ")
else
awaygoals = left(ci_t9,3," ")
say
say center(ci_t10"'"cupname"'",78)
say "-------------------------------------------------------------------------------"
say
say ci_t11" "awaygoals" "ci_t12
say ci_t13" "cuph
if pos("MANUAL",scht) > 0 then
say ci_t14" "ci_t15
else
say ci_t14" "ci_t16
say ci_t17" "third
say
say ci_t18" "rndcnt" "ci_t19
say ci_t20
say
say ci_t21
ci_line = ""
do ci_l=1 to length(ci_t21)+5
ci_line = ci_line||"-"
end
say ci_line
say
do i=1 to rndcnt
rndmsg = ""
if pos("1st",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t39)" "cs_t28,23)
if pos("2nd",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t40)" "cs_t28,23)
if pos("3rd",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t41)" "cs_t28,23)
if pos("4th",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t42)" "cs_t28,23)
if pos("5th",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t43)" "cs_t28,23)
if pos("Quart",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t35),23)
if pos("Semi",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t33),23)
if pos("Third",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t36),23)
if pos("Final",rnds.i) > 0 then rndmsg = rndmsg||left(strip(cs_t30),23)
if pos("No Ext.Time",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t3),19)
if pos("E.T If Rep.",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t4),19)
if pos("Extra Time",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t5),19)
if pos("No Pens.",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t6),21)
if pos("Pen If Rep.",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t7),21)
if pos("Penalties",rnds.i) > 0 then rndmsg = rndmsg||left(strip(fc_t8),21)
if pos("2 Legs",rnds.i) > 0 then rndmsg = rndmsg||fc_t2
say rndmsg
end
say
say "_______________________________________________________________________________"
say
say
say ci_t22
ci_line = ""
do ci_l=1 to length(ci_t22)
ci_line = ci_line||"-"
end
say ci_line
say
say ci_t23
say
say ci_t24
ci_line = ""
do ci_l=1 to length(ci_t24)
ci_line = ci_line||"-"
end
say ci_line
do i=1 to tcount
say left(i,3,' ')" "bstats.i
end
say
say
say ci_t25" "tcount
ci_line = ""
do ci_l=1 to length(ci_t25)
ci_line = ci_line||"-"
end
say ci_line
say
do i=1 to tcount by 2
a = i + 1
say left(teams.i,30,' ')" "teams.a
end
say
say "_______________________________________________________________________________"
say
if tleg_no = 0 then legged = "Blank"
if tleg_no = 1 then legged = "1 Leg"
if tleg_no = 2 then legged = "2 Legs"
tempname = ci_t26" : "bettername(word(rnds.crond,1),legged)
say tempname
uline = ''
do i=1 to length(tempname)
uline = uline||"-"
end
say uline
say
do i=1 to mcount
if matches.i ~= "" then
say matches.i
end
say
if pos("Yes",cuph) > 0 & exists(league_file||input4_file) > 0 then do
say "_______________________________________________________________________________"
say
say ci_t27
ci_line = ""
do ci_l=1 to length(ci_t27)
ci_line = ci_line||"-"
end
say ci_line
say
if open(datafile,league_file || input4_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(first,line) > 0 then do
parse var line "*WINNER="wteam
say wteam
end
end
close(datafile)
end
else do
say
say ci_error
say
say ci_t2"'"league_file || input4_file"'"
exit
end
say
end
say "-------------------------------------------------------------------------------"
say
exit
/* Routine ----------------------------------------------------------- */
bettername:
parse arg crn,legless
trdn = strip(substr(crn,1,1))
if datatype(trdn,'n') = 1 then do
parse var crn roundno" "extra
trn = strip(crn)" "cs_t28" "extra
end
else do
if pos(cs_t30,crn) > 0 then do
parse var crn . " "extra
if pos(cs_t31,crn) > 0 then
trn = cs_t30" "extra
else
trn = cs_t30
end
if pos(strip(cs_t45),crn) > 0 then do
parse var crn . " "extra
if pos(cs_t31,crn) > 0 then
trn = cs_t32" "extra
else
trn = cs_t33
end
if pos(strip(cs_t44),crn) > 0 then do
parse var crn . " "extra
if pos(cs_t31,crn) > 0 then
trn = cs_t34" "extra
else
trn = cs_t35
end
if pos(strip(cs_t46),crn) > 0 then do
trn = cs_t36
end
end
if pos("1 Leg",legless) > 0 then
trn = trn||" ("cum_t32")"
if pos("2 Legs",legless) > 0 then
trn = trn||" ("cum_t33")"
return trn
/* ------------------------------------------------------------------- */